<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta content="App Inventor for Android" name="description">
    <meta content="Android, Blocks App Inventor, Mobile, Phone, IDE" name="keywords">
    <title>
      TinyWebDB - App Inventor for Android
    </title>
    <link href="/static/images/appinventor-16.png" rel="SHORTCUT ICON" type="image/ico">
    <link href="/static/images/appinventor-16.png" rel="icon" type="image/png">
    <link href="/static/css/appinventor.css" rel="stylesheet">
    <script src="http://www.google.com/js/gweb/analytics/autotrack.js">
</script>
    <script>
  var tracker = new gweb.analytics.AutoTrack({
        profile: 'UA-5856106-2'
      });
    </script>
    <style>
img.c2 {border-width:0}
    div.c1 {clear:both;}
    </style>
  </head>
  <body>
    <div id="aiac">
      <div class="main-container">
        <div class="header">
          <div class="header-title">
            <a href="/about/"><img alt="" src="/static/images/appinventor_logo.gif"></a>
          </div>
          <form action="http://www.google.com/cse" id="cse-search-box">
            <input name="cx" type="hidden" value="011848991959401852367:xnrcbhk2zus"> <input name=
            "ie" type="hidden" value="UTF-8">
            <div class="header-search">
              <div class="header-search-query">
                <input class="textbox" name="q" type="text">
              </div>
              <div class="header-search-button">
                <input name="sa" src="/static/images/search-button.png" type="image">
              </div>
            </div>
          </form><script src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"
         >
</script>
          <div class="header-login">
            <div class="header-login-greeting">
              Learn about App Inventor
            </div>
          </div>
        </div>
        <div class="customhr customhr-green"></div>
        <div id="navigation">
          <div id="navigation-links">
            <div class="navigation-link-option" id="navigation-link-home">
              <a href="/about/">About</a>
            </div>
            <div class="navigation-link-option navigation-link-active" id="navigation-link-learn">
              <a href="/learn/">Learn</a>
            </div>
            <div class="navigation-link-option" id="navigation-link-forum">
              <a href="/forum/">Forum</a>
            </div>
            <div class="navigation-link-option" id="navigation-link-myappinventor">
              <a href="http://appinventor.googlelabs.com/ode/Ya.html" target="_blank">My
              Projects</a>
            </div>
          </div>
          <div id="navigation-breadcrumb">
            <a href="/learn/">Learn</a> &gt; <a href="/learn/reference/">Reference</a> &gt;
            TinyWebDB &gt;
          </div>
          <div class="c1"></div>
        </div>
        <div class="customhr customhr-gray"></div>
        <div class="content">
          <div class="content-body">
            <div class="learn-page">
              <h1>
                Creating a Custom TinyWebDB Service
              </h1>
              <p>
                <span class="ButtonText">TinyWebDB</span> is an App Inventor component that allows
                you to store data persistently in a database on the web. Because the data is stored
                on the web instead of a particular phone, <span class="ButtonText">TinyWebDB</span>
                can be used to facilitate communication between phones and apps (e.g., multi-player
                games).
              </p>
              <p>
                By default, the <span class="ButtonText">TinyWebDB</span> component stores data on
                a test service provided by App Inventor, <a href=
                "http://appinvtinywebdb.appspot.com/">http://appinvtinywebdb.appspot.com/</a>. This
                service is helpful for testing, but it is shared by all App Inventor users, and it
                has a limit of 1000 entries. If you use it, your data will be overwritten
                eventually.
              </p>
              <p>
                For most apps you write, you'll want to create a custom web service that isn't
                shared with other App Inventor apps and programmers. You need not be a programmer
                to do so-- just follow the instructions below and you'll have your own service
                within minutes.
              </p>
              <p>
                To create your own web service, follow these instructions:
              </p>
              <ul>
                <li>Download App Engine for Python at <a href="http://code.google.com/appengine/">
                  http://code.google.com/appengine/</a>. After installing it, run the
                  GoogleAppEngineLauncher by clicking its icon.
                </li>
                <li>Download this <a href="tinywebdbassets/customtinywebdb.zip">sample code</a>. It
                is a zip file containg the source code for your custom tinywebdb web service<br>
                </li>
                <li>Unzip the downloaded zip file. It will create a folder named <span class=
                "ButtonText">customtinywebdb</span>. You can rename it if you want.<br>
                </li>
                <li>In the GoogleAppEngineLauncher, choose <span class="ButtonText">File | Add
                Existing Application</span>. Browse to set the Path to the <span class=
                "ButtonText">customtinywebdb</span> folder you just unzipped. Then click the Run
                button. This will launch a test web service that runs on your local machine.
                </li>
                <li>You can test the service by opening a browser and entering "localhost:8080" as
                the URL. You'll see the web page interface to your web service. The end-goal of
                this service is to communicate with a mobile app created with App Inventor. But the
                service provides a web page interface to the service to help programmers with
                debugging. You can invoke the get and store operations by hand, view the existing
                entries, and also delete individual entries
                </li>
                <li>Your app is not yet on the web, and thus not yet accessible to an App Inventor
                app. To get it there, you need to upload it to Google's App Engine servers.
                  <ul>
                    <li>In the GoogleAppEngineLauncher, choose <span class=
                    "ButtonText">Dashboard</span>. Enter your Google account information and you'll
                    be taken to an App Engine dashboard.
                    </li>
                    <li>Choose <span class="ButtonText">Create an Application</span>. You'll need
                    to specify a globally unique Application Identifier. Remember the Application
                    identifier as you'll need it later. Provide a name to your app and click
                    <span class="ButtonText">Create Application</span> to submit. If your
                    Identifier was unique, you now have a new, empty app on Google's servers.
                    </li>
                    <li>Open a text editor on your local computer and open the file <span class=
                    "ButtonText">app.yaml</span> within the <span class=
                    "ButtonText">customtinywebdb</span> folder you unzipped. Modify the first line
                    so that the application matches the application identifier you set at Google.
                    </li>
                    <li>In GoogleAppEngineLauncher, choose <span class="ButtonText">Deploy</span>
                    and follow the steps for deploying your app.
                    </li>
                  </ul>
                </li>
                <li>Test to see if your app is running on the web. In a browser, enter
                myapp.appspot.com, only substitute your application identifier for "myapp". The app
                should look the same as when you ran it on the local test server. Only now, it's on
                the web and you can access it from your App Inventor for Android app.
                </li>
              </ul>
              <p>
                Your App Inventor apps can store and retrieve data using your new service. Just do
                the following:
              </p>
              <ul>
                <li>Drag in a TinyWebDB component into the Component Designer.
                </li>
                <li>Modify the ServiceURL property from the default <a href=
                "http://appinvtinywebdb.appspot.com/">http://appinvtinywebdb.appspot.com/</a> to
                your web service.
                </li>
                <li>Any StoreValue operations (blocks) will store data at your service, and any
                GetValue operations will retrieve from your service.<br>
                  <br>
                  <br>
                </li>
              </ul>
            </div>
          </div>
        </div>
      </div>
      <div class="footer">
        <div class="footer-legal">
          <p>
            <a href="http://creativecommons.org/licenses/by/3.0/" rel="license"><img alt=
            "Creative Commons License" class="c2" src=
            "http://i.creativecommons.org/l/by/3.0/88x31.png"></a><br>
            This work is licensed under a <a href="http://creativecommons.org/licenses/by/3.0/"
            rel="license">Creative Commons Attribution 3.0 Unported License</a> .
          </p>
          <p>
            ©2011 Google<br>
            <a href="/about/index.html">About</a> | <a href="/about/privacy.html">Privacy</a> |
            <a href="/about/termsofservice.html">Terms</a>
          </p>
        </div>
        <div class="footer-lastupdate">
          <script>
    if (document.lastModified != '') {
                var m = "Page last updated: " + document.lastModified;
                var p = m.length-8;
                document.writeln("<center>");
                document.write(m.substring(p, 0));
                document.writeln("<\/center>");
              }
          </script>
        </div>
      </div>
    </div>
  </body>
</html>